package com.mobile.web.config.shiro;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 统一异常处理类<br>
 * 捕获程序所有异常，针对不同异常，采取不同的处理方式
 *
 */
@ControllerAdvice
public class ExceptionHandleController {
	private Logger logger = LogManager.getLogger(ExceptionHandleController.class);

  @ExceptionHandler(UnauthorizedException.class)
  public String handleShiroException(Exception ex) {
	  logger.info("ExceptionHandleController.class->登录用户操作权限判断：没有相应URL访问权限。");
	  return "redirect:/noper/noAuth";
  }

  @ExceptionHandler(AuthorizationException.class)
  public String AuthorizationException(Exception ex) {
	  logger.info("ExceptionHandleController.class->登录用户操作权限判断：没有相应处理权限。");
	  return "";
//      return "redirect:/error/401";
  }
}
